import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StaffVO, StaffForm, StaffQuery } from '@/api/office/staff/types';

/**
 * 查询教职工信息列表
 * @param query
 * @returns {*}
 */

export const listStaff = (query?: StaffQuery): AxiosPromise<StaffVO[]> => {
  return request({
    url: '/office/staff/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询教职工信息列表
 * @param query
 * @returns {*}
 */

export const listWithPostAndDept = (query?: StaffQuery): AxiosPromise<StaffVO[]> => {
  return request({
    url: '/office/staff/listWithPostAndDept',
    method: 'get',
    params: query
  });
};

export const attendanceGroupPage = (query?: StaffQuery): AxiosPromise<StaffVO[]> => {
  return request({
    url: '/office/staff/attendance-group/page',
    method: 'get',
    params: query
  });
};

/**
 * 查询教职工信息详细
 * @param staffId
 */
export const getStaff = (staffId: string | number): AxiosPromise<StaffVO> => {
  return request({
    url: '/office/staff/' + staffId,
    method: 'get'
  });
};

/**
 * 新增教职工信息
 * @param data
 */
export const addStaff = (data: StaffForm) => {
  return request({
    url: '/office/staff',
    method: 'post',
    data: data
  });
};

/**
 * 修改教职工信息
 * @param data
 */
export const updateStaff = (data: StaffForm) => {
  return request({
    url: '/office/staff',
    method: 'put',
    data: data
  });
};

export const editAttendanceGroup = (data: any) => {
  return request({
    url: '/office/staff/attendance-group',
    method: 'put',
    data: data
  });
};

export const removeAttendanceGroup = (id: string | number | Array<string | number>) => {
  return request({
    url: '/office/staff/attendance-group/' + id,
    method: 'delete'
  });
};

/**
 * 删除教职工信息
 * @param staffId
 */
export const delStaff = (staffId: string | number | Array<string | number>) => {
  return request({
    url: '/office/staff/' + staffId,
    method: 'delete'
  });
};
